package leetcode;

public class LC1456 {

    boolean isAEIOU(char c) {
        if ( c != 'a' && c != 'e' && c != 'i' && c != 'o' && c != 'u')
            return false;
        return true;
    }

    public int maxVowels(String s, int k) {

        int cnt = 0;

        int  j = 0;
        for (j = 0; j < k; j++) {
            if (isAEIOU(s.charAt(j))) {
                cnt++;
            }
        }
        int ans = cnt;
        int i = 1;
        while (i < s.length() && j < s.length()) {
            if (isAEIOU(s.charAt(i-1)))
                cnt --;
            if (isAEIOU(s.charAt(j)))
                cnt ++;
            i++;
            j++;
            ans = Math.max(ans,cnt);
        }
        return ans;
    }
}
